package com.itheima.d3_stream;

import java.util.*;
import java.util.stream.Stream;

/*
        目标：掌握Stream流的创建。

        1 单列集合获取Stream流
        2 双列集合获取Stream流
        3 数组获取Stream流
        4 同一种类型多个数据获取Stream流
 */
public class StreamTest2 {
    public static void main(String[] args) {
        // 1、如何获取List集合的Stream流？
        List<String> names = new ArrayList<>();
        Collections.addAll(names, "张三丰","张无忌","周芷若","赵敏","张强");
        names.stream().filter(s->s.startsWith("张")).filter(s -> s.length() == 3).forEach(System.out::println);

        HashMap<String, String> map = new HashMap<>();
        map.put("1","a");
        map.put("2","b");
        map.put("3","c");
        Set<Map.Entry<String, String>> entries = map.entrySet();
        entries.forEach(System.out::println);

        String[] arrays = {"李广","隋炀帝","商纣王","秦始皇"};
        Stream<String> stream = Arrays.stream(arrays);
        stream.forEach(System.out::println);

        Stream.of("扬州","郑州","颍川","江东").forEach(System.out::println);
    }
}
